// 已有 I 和 X1 以及 `impl From<&mut I> for X1`
struct I(i32);

struct X1;
impl From<&mut I> for X1 {
    fn from(p: &mut I) -> X1 {
        p.0 = 1;
        X1
    }
}
// 必须引入这个中间函数
fn x1(p: &mut I) -> X1 {
    X1::from(p)
}

// 我想要 `impl From<&mut I> for XT`
struct XT(X1, X1);
impl From<&mut I> for XT {
    fn from(p: &mut I) -> XT {
        XT(x1(p), x1(p))
    }
}

// value used here after move
fn from_twice_fail(p: &mut I) {
    let x11 = X1::from(&mut *p);
    let x12 = X1::from(&mut *p);
}
// 跟上面的函数有啥区别，为什么可以？
fn from_twice(p: &mut I) {
    let x11 = x1(p);
    let x12 = x1(p);
}

fn main() {
    let mut s = 11; //1
    let b = &mut s; //2
    let c: &mut i32 = b; //3 let c = &mut s; 会报错，因为这种写法是borrow不是reborrow
    *c = 13; //4
    *b = 12; //5
}
